home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Documents / NeXTAnswers / appkit.647 < prev    next >
Text File  |  1992-02-06  |  2KB  |  48 lines

  1. {\rtf0\ansi{\fonttbl\f0\fnil Times-Roman;\f2\fmodern Courier;\f1\fswiss Helvetica;}
  2. \paperw12740
  3. \paperh8500
  4. \margl120
  5. \margr120
  6. {\colortbl\red0\green0\blue0;}
  7. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\b0\i0\ul0\fs28 Appkit Text Margin\
  8.     \
  9. Q:  How do the Text object margins work?\
  10.  
  11. \i     \
  12.  
  13. \i0 A: 
  14. \fc0  The margins do work, but it's difficult to correctly set them. You need to offset the values by the frame rectangle of the text.  The following code snippet illustrates the necessary steps:\
  15. \
  16.  
  17. \f2\fs24 /* This routine assumes that you have defined currentDocText somewhere else */ \
  18. \
  19. #define    DESIREDleftMARGIN    some int value\
  20. #define    DESIREDrightMARGIN    some int value\
  21. #define    DESIREDtopMARGIN    some int value\
  22. #define    DESIREDbottomMARGIN    some int value\
  23. \
  24.  
  25. \pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\fc0 - setMargins:sender\
  26. \{\
  27.     NXRect    aRect;\
  28.     \
  29.     /* Get the current frame values */\
  30.     [currentDocText getFrame:&aRect];\
  31.     [currentDocText setMarginLeft: NX_X(&aRect) + DESIREDleftMARGIN\
  32.             right: - NX_X(&aRect) + DESIREDrightMARGIN\
  33.             top: NX_Y(&aRect) + DESIREDtopMARGIN\
  34.             bottom: - NX_Y(&aRect) + DESIREDbottomMARGIN]; ];\
  35.     return self;\
  36. \}\
  37.  
  38. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\fs28\fc0 \
  39. If you call 
  40. \f2\fs24 getMarginLeft:right:top:bottom:
  41. \f0\fs28 , the returned values are the same as the ones you provide to 
  42. \f2\fs24 setMarginLeft:right:top:bottom:
  43. \f0\fs28 .  So, to determine the "true" margins, you need to subtract the frame's dimensions.\
  44. \
  45. QA647\
  46. \
  47.  
  48.